package com.pak;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class PakFile {
	
    private String name;
    private byte[] body;
    
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public byte[] getBody() {
		return body;
	}
	public void setBody(byte[] body) {
		this.body = body;
	}
	
	public int getBytesSize(){
		return 4 + name.getBytes().length + 4 + body.length;
	}
	
	public byte[] getBytes(){
		ByteBuffer bf = ByteBuffer.allocate(getBytesSize());
		bf.order(ByteOrder.BIG_ENDIAN);
		bf.putInt(name.getBytes().length);
		bf.put(name.getBytes());
		bf.putInt(body.length);
		bf.put(body);
		bf.flip();
		
		return bf.array();
	}
        
}